package com.power.sifa.base.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
*  公告推送类实体类
*/

@Entity
@ApiModel(value="公告推送类")
@Data
@Table(name="Apl_common_notice",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@Builder
//@IdClass(Apl_common_notice.Apl_common_noticePK.class) 用于复合组件
public class Apl_common_notice extends BaseModel implements Serializable {
	
	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "序号")
    private String id;

    @ApiModelProperty(value = "内容")
    private String content;

    @ApiModelProperty(value = "创建时间", example="2020-10-22 10:03:22")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createtime;

    @ApiModelProperty(value = "告警时间", example="2020-10-22 10:03:22")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date warntime;

    @ApiModelProperty(value = "完成时间", example="2020-10-22 10:03:22")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date finishtime;

    @ApiModelProperty(value = "通知人员")
    private String userid;

    @ApiModelProperty(value = "消息类型")
    private Integer msgtype;

    @ApiModelProperty(value = "跳转路由")
    private String router;

    /**
     *  消息类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_noticemsg", valuefield="msgtype")
    private String msgtype_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("content", this.getContent());
        map.put("createtime", this.getCreatetime());
        map.put("warntime", this.getWarntime());
        map.put("finishtime", this.getFinishtime());
        map.put("userid", this.getUserid());
        map.put("msgtype_text", this.msgtype_text);
        map.put("msgtype", this.getMsgtype());
        map.put("router", this.getRouter());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_common_noticePK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Apl_common_noticePK pk = (Apl_common_noticePK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}